import * as BaseApi from './BaseApi.js';


import * as Config from './Config.js';

export const addMaintainColumn = (goodsId,columnName) => {

    let params={}
    params.token=sessionStorage.getItem("token")
    params.merchantId=sessionStorage.getItem("merchantId")
    params.goodsId=goodsId
    params.columnName=columnName

  return BaseApi.requestForm(Config.g_biz_url,'/goods/maintain/columnadd', params)
    .then(res => res)

}

export const queryColuMainInfo = (carGroupId) => {
  
      let params={}
      params.token=sessionStorage.getItem("token")
      params.merchantId=sessionStorage.getItem("merchantId")
      params.carGroupId=carGroupId
  
    return BaseApi.requestForm(Config.g_biz_url,'/car/group/linkquery', params)
      .then(res => res)

}
export const queryMaintainColumn = (goodsId) => {
    
        let params={}
        params.token=sessionStorage.getItem("token")
        params.merchantId=sessionStorage.getItem("merchantId")
        params.goodsId=goodsId
    
      return BaseApi.requestForm(Config.g_biz_url,'/goods/maintain/columnquery', params)
        .then(res => res)
 
}

export const addColumnGroup = (goodsId,carGroupName) => {
    
        let params={}
        params.token=sessionStorage.getItem("token")
        params.merchantId=sessionStorage.getItem("merchantId")
        params.goodsId=goodsId
        params.carGroupName = carGroupName
        console.log(params)
        return BaseApi.requestForm(Config.g_biz_url,'/car/group/add', params)
        .then(res => res)
    
}


export const queryColumnandGroup = (goodsId) => {
    
        let params={}
        params.token=sessionStorage.getItem("token")
        params.merchantId=sessionStorage.getItem("merchantId")
        params.goodsId=goodsId
    
      return BaseApi.requestForm(Config.g_biz_url,'/car/group/query', params)
        .then(res => res)
    
}


export const queryMaintainList =  (catId,carIdList) => {
        let params={}

        params.token=sessionStorage.getItem("token")
        params.merchantId=sessionStorage.getItem("merchantId")
        
        params.linkType = "CAR"
        params.linkIds=carIdList
        params.catId = catId
    
      return BaseApi.requestForm(Config.g_biz_url,'/maintain/info/query', params)
        .then(res => res)
    
}

export const addMaintainLinkAdd =  (groupId,carIds) => {
    let params={}
    params.token=sessionStorage.getItem("token")
    params.merchantId=sessionStorage.getItem("merchantId")
    params.carGroupId =groupId
    params.carIds = carIds

  return BaseApi.requestForm(Config.g_biz_url,'/car/group/linkadd', params)
    .then(res => res)

}
export const getCarGroupMainList =  (carGroupId) => {
  let params={}
  params.token=sessionStorage.getItem("token")
  params.merchantId=sessionStorage.getItem("merchantId")
  params.carGroupId =carGroupId

return BaseApi.requestForm(Config.g_biz_url,'/cargroup/maintaincolumn/linkquery', params)
  .then(res => res)

}

// 分组加栏目

export const addGroupNewMainList =  (carGroupId,maintainColumnIds) => {
  let params={}
  params.token=sessionStorage.getItem("token")
  params.merchantId=sessionStorage.getItem("merchantId")
  params.carGroupId =carGroupId
  params.maintainColumnIds = maintainColumnIds
return BaseApi.requestForm(Config.g_biz_url,'/cargroup/maintaincolumn/linkadd', params)
  .then(res => res)

}


//查询栏目下面的属性

export const queryEditAttribute =  (carGroupId,maintainColumnId) => {
  let params={}
  params.token=sessionStorage.getItem("token")
  params.merchantId=sessionStorage.getItem("merchantId")
  params.carGroupId =carGroupId
  params.maintainColumnId = maintainColumnId
return BaseApi.requestForm(Config.g_biz_url,'/cargroup/maintain/linkquery', params)
  .then(res => res)

}


// 编辑属性
export const editAttribute =  (self,model,carGroupId) => {
  Object.assign(model, {
    token: self.$store.getters.getToken,
    merchantId: self.$store.getters.getMerchantId,
    carGroupId:carGroupId
});
return BaseApi.requestForm(Config.g_biz_url,'/cargroup/maintain/linksave', model)
  .then(res => res)

}
// 删除分组
export const delGroup =  (self,carGroupId) => {
 let model =  {
    token: self.$store.getters.getToken,
    merchantId: self.$store.getters.getMerchantId,
    carGroupId:carGroupId
}
return BaseApi.requestForm(Config.g_biz_url,'/car/group/delete', model)
  .then(res => res)

}
//删除栏目
export const delColumn =  (self,carGroupMaintainColumnLinkId) => {
  let model =  {
     token: self.$store.getters.getToken,
     merchantId: self.$store.getters.getMerchantId,
     carGroupMaintainColumnLinkId:carGroupMaintainColumnLinkId
 }
 return BaseApi.requestForm(Config.g_biz_url,'/cargroup/maintaincolumn/linkdelete', model)
   .then(res => res)
 
 }

//查询商品绑定的车型列表
export const queryPDLinkCarList =  (self,model) => {
  Object.assign(model, {
    token: self.$store.getters.getToken,
    merchantUserId: self.$store.getters.getModel.merchantUserId
});
 return BaseApi.requestForm(Config.g_biz_url,'/goods/car/linkquery', model)
   .then(res => res)
 }


// 查询保养绑定数据

export const queryPlanList =  (self,model) => {
  Object.assign(model, {
    token: self.$store.getters.getToken,
    merchantUserId: self.$store.getters.getModel.merchantUserId
});
 return BaseApi.requestForm(Config.g_biz_url,'/maintenance/plan/linkquery', model)
   .then(res => res)
 }

// 单个添加关联



export const doPDLinkCarListByTemp =  (self,model) => {
  Object.assign(model, {
    token: self.$store.getters.getToken,
    merchantUserId: self.$store.getters.getModel.merchantUserId
});
 return BaseApi.requestForm(Config.g_biz_url,'/goods/car/linkaddbytemp', model)
   .then(res => res)
 }
//商品绑定车型
export const doPDLinkCarList =  (self,model) => {
  Object.assign(model, {
    token: self.$store.getters.getToken,
    merchantUserId: self.$store.getters.getModel.merchantUserId
});
 return BaseApi.requestForm(Config.g_biz_url,'/goods/car/linkadd', model)
   .then(res => res)
 }

// 单个绑定保养关联

export const doPlanLinkCarList =  (self,model) => {
  Object.assign(model, {
    token: self.$store.getters.getToken,
    merchantUserId: self.$store.getters.getModel.merchantUserId
});
 return BaseApi.requestForm(Config.g_biz_url,'/maintenance/plan/linkadd', model)
   .then(res => res)
 }


// 多个关联

export const doPDPlanCarListByTemp =  (self,model) => {
  Object.assign(model, {
    token: self.$store.getters.getToken,
    merchantUserId: self.$store.getters.getModel.merchantUserId
});
 return BaseApi.requestForm(Config.g_biz_url,'/maintenance/plan/linkaddbytemp', model)
   .then(res => res)
 }



//商品取消绑定车型
export const cancelPDLinkCarList =  (self,model) => {
  Object.assign(model, {
    token: self.$store.getters.getToken,
    merchantUserId: self.$store.getters.getModel.merchantUserId
});
 return BaseApi.requestForm(Config.g_biz_url,'/goods/car/linkdelete', model)
   .then(res => res)
 }

// 保养取消绑定
export const cancelPlanLinkCarList =  (self,model) => {
  Object.assign(model, {
    token: self.$store.getters.getToken,
    merchantUserId: self.$store.getters.getModel.merchantUserId
});
 return BaseApi.requestForm(Config.g_biz_url,'/maintenance/plan/linkdelete', model)
   .then(res => res)
 }

//查询栏目
export const queryColumnItem =  (self,model) => {
  Object.assign(model, {
    token: self.$store.getters.getToken,
    merchantUserId: self.$store.getters.getModel.merchantUserId
});
 return BaseApi.requestForm(Config.g_biz_url,'/goodsmaintain/column/query', model)
   .then(res => res)
 }
//修改栏目
export const saveColumnItem =  (self,model) => {
  Object.assign(model, {
    token: self.$store.getters.getToken,
    merchantUserId: self.$store.getters.getModel.merchantUserId
});
 return BaseApi.requestForm(Config.g_biz_url,'/goodsmaintain/column/save', model)
   .then(res => res)
 }


// POST /goods/maintain/linkadd


// http://116.62.22.58:8030/goods/maintain/columnandgroupquery





    